<template>
  <div class="mysuperior">
    <x-header v-show="!isWeChar">
      <div slot="default" class="common__header--title">{{pageTitle}}</div>
      <div @click="goBack" slot="overwrite-left"><img slot="icon" src="~assets/x3/ico/goback1.png" class="go-back"></div>
    </x-header>
    <!-- 上级信息 -->
    <div class="superior_info">

      <Group>
        <cell title="昵称" :value="superiorDto.nickName"></cell>
        <cell title="姓名" :value="superiorDto.userName"></cell>
        <cell title="电话" :value="superiorDto.mobile | filter_mobile"></cell>
        <cell title="邮箱" :value="superiorDto.email"></cell>
        <cell title="最后登录时间" :value="superiorDto.lastloginDate"></cell>
      </Group>
    </div>
    <!-- 提示信息 -->
    <toast v-model="showToast" type="warn">{{showToastText}}</toast>
  </div>
</template>
<script>
import { XHeader, Group, Cell, Toast } from "vux";
import { RouteUrl, Mutations } from "src/common/const";
import { RequestUrl } from "src/common/url";
import { mapState } from "vuex";

export default {
  components: { XHeader, Group, Cell, Toast },
  computed: mapState(["user", "isWeChar"]),
  data() {
    return {
      pageTitle: "我的上级",//页面标题名称
      showToastText: "", //提示信息
      showToast: false, //是否提示
      superiorDto: {},//上级用户信息
    };
  },
  filters: {
    filter_mobile(val) {
      if (typeof (val) != 'undefined' && val != null) {
        return val.substring(0, 3) + "*****" + val.substring(val.length - 3, val.length);
      }
      return val;
    },
    filter_idNumber(val) {
      if (typeof (val) != 'undefined' && val != null && val.length >= 15) {
        return val.substring(0, 5) + "**********" + val.substring(val.length - 3, val.length);
      }
      return val;
    },
    filter_num(val) {
      if (typeof (val) != 'undefined' && val != null && val.length >= 16) {
        return val.substring(0, 4) + " **** **** **** " + val.substring(val.length - 3, val.length);
      }
      return val;
    }
  },
  methods: {
    //返回
    goBack() {
      this.$common.goBackUrl(this, RouteUrl.ACCOUNT);
    },
    //初始化当前页面信息
    initPage() {
      let _this = this;
      let data = { TYPE: "FORM", comCode: this.user.userDto.comCode, };
      //查询上级用户
      _this.$common.storeCommit(_this, Mutations.UPDATE_LOADING_STATUS, true);
      _this.$http.post(RequestUrl.FIND_USER_BY_COMCODE, data).then(function (res) {
        _this.$common.storeCommit(_this, Mutations.UPDATE_LOADING_STATUS, false);
        if (res.state != 0) {
          _this.showToastText = res.result; _this.showToast = true; return;
        }
        _this.superiorDto = res.result;
      });
    }
  },
  mounted() {
    document.title = this.pageTitle;
    this.$init.subPageInit(this);
    //初始化当前页面信息
    this.initPage();
  }
};
</script>
<style lang="scss" scoped>
.mysuperior {
  padding-bottom: 100px;
  .superior_info {
  }
}
</style>
